#include <stdio.h>  
#include <stdlib.h>  
  
// 定义二叉树结点结构体  
struct TreeNode {  
    int val;  
    struct TreeNode *left;  
    struct TreeNode *right;  
};  
  
// 创建二叉树  
struct TreeNode* createTree() {  
    int val;  
    scanf("%d", &val);
    if (val == -1) {   
        return NULL;  
    }  
    struct TreeNode* node = (struct TreeNode*)malloc(sizeof(struct TreeNode));  
    node->val = val;  
    node->left = createTree();
    node->right = createTree();
    return node;
}  
  
// 打印从根结点到叶子结点的路径  
void printPath(struct TreeNode* root, int depth) {  
    if (root == NULL) { 
        return;  
    }  
    for (int i = 0; i < depth; i++) {  
        printf("%d ", root->val);  
    }  
    printf("\n");  
    if (root->left == NULL && root->right == NULL) {  
        printf("Path ended\n");  
        return;  
    } else {   
        printPath(root->left, depth + 1);  
        printPath(root->right, depth + 1);  
    }  
}  
  
// 主函数，测试代码  
int main() {  
    struct TreeNode* root = createTree();  
    printPath(root, 0); 
    return 0;  
}